package edu.ptu.shortlink.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.ptu.shortlink.admin.common.convention.result.Result;
import edu.ptu.shortlink.admin.remote.ShortLinkRemoteService;
import edu.ptu.shortlink.admin.remote.dto.req.ShortLinkGroupStatsAccessRecordReqDTO;
import edu.ptu.shortlink.admin.remote.dto.req.ShortLinkGroupStatsReqDTO;
import edu.ptu.shortlink.admin.remote.dto.req.ShortLinkStatsAccessRecordReqDTO;
import edu.ptu.shortlink.admin.remote.dto.req.ShortLinkStatsReqDTO;
import edu.ptu.shortlink.admin.remote.dto.resp.ShortLinkStatsAccessRecordRespDTO;
import edu.ptu.shortlink.admin.remote.dto.resp.ShortLinkStatsRespDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: shortlink
 * @BelongsPackage: edu.ptu.shortlink.admin.controller
 * @Author: HYJ
 * @CreateTime: 2025-05-10  22:42
 * @Description: 用户端-短链接访问统计控制层
 * @Version: 1.0
 */
@RestController
@RequiredArgsConstructor
public class ShortLinkStatsController {

    private final ShortLinkRemoteService shortLinkRemoteService;

    /**
     * 单个短链接统计
     */
    @GetMapping("api/short-link/admin/v1/stats")
    public Result<ShortLinkStatsRespDTO> shortLinkStats(ShortLinkStatsReqDTO requestParam) {
        return shortLinkRemoteService.oneShortLinkStats(requestParam);
    }

    /**
     * 分页查询日志记录
     */
    @GetMapping("api/short-link/admin/v1/stats/access-record")
    public Result<Page<ShortLinkStatsAccessRecordRespDTO>> shortLinkStatsAccessRecord(ShortLinkStatsAccessRecordReqDTO requestParam) {
        return shortLinkRemoteService.shortLinkStatsAccessRecord(requestParam);
    }

    /**
     * 分页分组查询日志记录
     */
    @GetMapping("api/short-link/v1/admin/stats/access-record/group")
    public Result<Page<ShortLinkStatsAccessRecordRespDTO>> groupShortLinkStatsAccessRecord(ShortLinkGroupStatsAccessRecordReqDTO requestParam) {
        return shortLinkRemoteService.groupShortLinkStatsAccessRecord(requestParam);
    }

    /**
     * 分组短链接统计
     */
    @GetMapping("api/short-link/v1/admin/stats/group")
    public Result<ShortLinkStatsRespDTO> shortLinkStatsGroup(ShortLinkGroupStatsReqDTO requestParam) {
        return shortLinkRemoteService.groupShortLinkStats(requestParam);
    }
}
